import {
  axios
} from '@/utils/request'
// 零件版本列表
function getVersionList (data) {
  return axios({
    url: '/software-service/version/list',
    method: 'get',
    params: data
  })
}
// 新增版本
function addVersion (data) {
  return axios({
    url: '/software-service/version',
    method: 'post',
    data
  })
}
//自动创建ECU版本
function autoCreateECUItem(data) {
  return axios({
      url: '/software-service/version/addAutoTestEcuVersion',
      method: 'post',
      data
  })
}
// 编辑版本
function editVersion (data) {
  return axios({
    url: '/software-service/version',
    method: 'put',
    data
  })
}
// 版本详情
function versionInfor (params) {
  return axios({
    url: '/software-service/version/info',
    method: 'get',
    params
  })
}
// 删除ECU版本
function deleteVersion (data) {
  return axios({
    url: '/software-service/version',
    method: 'delete',
    data
  })
}
// 启用停用版本
function enableDisableVersion (data) {
  return axios({
    url: '/software-service/version/ecu/enable',
    method: 'put',
    data
  })
}
// 所有版本
function allVersion (params) {
  return axios({
    url: '/software-service/version/select/' + params.versionType,
    method: 'get',
    params
  })
}
// 版本黑名单
function versionBlackList (params) {
  return axios({
    url: '/software-service/version/block/vehicle/list',
    method: 'get',
    params
  })
}
// 版本黑名单删除
function versionBlackDelete (data) {
  return axios({
    url: '/software-service/version/block/vehicle',
    method: 'delete',
    data
  })
}
// 版本黑名单导出
function versionBlackExport (params) {
  return axios({
    url: '/software-service/version/block/vehicle/export',
    method: 'get',
    params,
    responseType: 'blob'
  })
}
// ECU软件版本选择
function versionEcuSelect (params, versionType) {
  return axios({
    url: '/software-service/version/ecu/select/' + versionType.toLowerCase(),
    method: 'get',
    params
  })
}

// sota升级策略版本列表
function sotaVersionEcuSelect (params) {
  return axios({
    url: '/software-service/software/upgradeEcuVersion/list',
    method: 'get',
    params
  })
}
// 验证是否有差分素材包
function validMaterialFileId (params) {
  return axios({
    url: `software-service/version/materialFileId`,
    method: 'get',
    params
  })
}

export default {
  getVersionList,
  addVersion,
  editVersion,
  versionInfor,
  enableDisableVersion,
  deleteVersion,
  allVersion:allVersion,
  versionBlackList,
  versionBlackDelete,
  versionBlackExport,
  versionEcuSelect:versionEcuSelect,
  sotaVersionEcuSelect,
  validMaterialFileId,
  autoCreateECUItem
}
